package com.zhengdongzulin.zuke.app.main.apartment.sign

import androidx.lifecycle.rxLifeScope
import com.lxj.androidktx.livedata.StateLiveData
import com.zhengdongzulin.zuke.app.Api
import com.zhengdongzulin.zuke.app.data.*
import com.zhengdongzulin.zuke.base.BaseViewModel
import rxhttp.wrapper.param.RxHttp
import rxhttp.wrapper.param.toResponse

class ReserveSearchVm : BaseViewModel() {

    var room_type_house_list: StateLiveData<MutableList<ReserveSearchListData>> = StateLiveData()

    fun room_type_house_list(roomTypeId: String, fangNoLike: String = "") {
        rxLifeScope.launch(
            {
                var r = RxHttp.postJson(Api.ROOM_TYPE_HOUSE_LIST)
                    .add("roomTypeId", roomTypeId)
                    .add("fangNoLike", fangNoLike)
                    .toResponse<MutableList<ReserveSearchListData>>()
                    .await()
                room_type_house_list.postValueAndSuccess(r)
            }, {
                assignment(it, room_type_house_list)
            }
        )
    }

}